# 将识别数独图像转换成标准数独图像，并显示答案

from typing import List
import matplotlib.pyplot as plt
import numpy as np
plt.rcParams['figure.dpi'] =  200    #分辨率

def plot_sudoku(board: List[List[str]], board_init: List[List[str]]):

    fig, ax = plt.subplots(figsize=(6, 6))
    ax.axis('off')
    
    # 显示数独的数字
    for i in range(9):
        for j in range(9):
            if board_init[i][j] == 0: # 答案数字显示红色
                ax.text(j + 0.5, 8.5 - i, str(board[i][j]), ha='center', va='center', fontsize=16, color='red')
            else:
                ax.text(j + 0.5, 8.5 - i, str(board[i][j]), ha='center', va='center', fontsize=16)
    # 绘制粗线，表示每个3x3方块的边界
    for i in range(10):
        lw = 2 if i % 3 == 0 else 0.5
        ax.plot([i, i], [0, 9], color='black', lw=lw)  # 竖线
        ax.plot([0, 9], [i, i], color='black', lw=lw)  # 横线
    
    # 设置棋盘的大小为9x9
    ax.set_xlim(0, 9)
    ax.set_ylim(0, 9)
    
    # 显示图像
    plt.show()


